home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / signature_switch-1.6.1-tb.xpi / chrome / signatureswitch.jar / content / options.js < prev    next >
Text File  |  2008-03-07  |  22KB  |  683 lines

  1. var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
  2. var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
  3.  
  4. var elementIDs = [      "shortcut_onoff_key",
  5.                         "shortcut_onoff_modifier_accel",
  6.                         "shortcut_onoff_modifier_alt",
  7.                         "shortcut_onoff_modifier_control",
  8.                         "shortcut_onoff_modifier_meta",
  9.                         "shortcut_onoff_modifier_shift",
  10.                         "shortcut_cycle_key",
  11.                         "shortcut_cycle_modifier_accel",
  12.                         "shortcut_cycle_modifier_alt",
  13.                         "shortcut_cycle_modifier_control",
  14.                         "shortcut_cycle_modifier_meta",
  15.                         "shortcut_cycle_modifier_shift",
  16.                         "offbydefault",
  17.                         "contextmenu",
  18.                         "composerpath",
  19.                         "encoding",
  20.                         "preloadexecutable",
  21.                         "preloadexecutablepath",
  22.                         "preloadexecutablewait",
  23.                         "initdelay",
  24.                         "autoswitchpriority"    ];
  25.  
  26. var ssTree;
  27. var ssTreeView;
  28.  
  29. treeView.prototype = {
  30.  
  31.     invalidate: function()
  32.     {
  33.         this.treebox.invalidate();
  34.     },
  35.  
  36.     swap: function(idx1, idx2)
  37.     {
  38.         if ((idx1 == idx2) || (idx1 < 0) || (idx2 < 0))
  39.             return;
  40.  
  41.         var temp = this.items[idx1];
  42.  
  43.         this.items[idx1] = this.items[idx2];
  44.         this.items[idx2] = temp;
  45.  
  46.         if (this.defaultsignature == idx1)
  47.         {
  48.             this.defaultsignature = idx2;
  49.         }
  50.         else if (this.defaultsignature == idx2)
  51.         {
  52.             this.defaultsignature = idx1;
  53.         }
  54.     },
  55.  
  56.     insertItem: function(newItem)
  57.     {
  58.         try
  59.         {
  60.             this.items.push(newItem);
  61.             this.treebox.rowCountChanged(this.rowCount, 1);
  62.         }
  63.         catch (err)
  64.         {
  65.             alert(err);
  66.         }
  67.     },
  68.  
  69.     deleteSelectedItem: function()
  70.     {
  71.         try
  72.         {
  73.             var selIdx = this.selection.currentIndex;
  74.  
  75.             if (selIdx < 0)
  76.                 return;
  77.  
  78.             var newItems = new Array();
  79.  
  80.             for (var i = 0; i < this.items.length; i++)
  81.             {
  82.                 if (i != selIdx)
  83.                     newItems.push(this.items[i]);
  84.             }
  85.  
  86.             if (selIdx == this.defaultsignature)
  87.                 this.defaultsignature = -1;
  88.  
  89.             this.items = newItems;
  90.             this.treebox.rowCountChanged(selIdx, -1);
  91.  
  92.             if (newItems.length > 0)
  93.                 this.selection.select(selIdx == 0 ? 0 : selIdx - 1);
  94.         }
  95.         catch (err)
  96.         {
  97.             alert(err);
  98.         }
  99.     },
  100.  
  101.     getCellText: function(row, column)
  102.     {
  103.         switch (typeof(column) == "object" ? column.id : column)
  104.         {
  105.             case "default":
  106.               return (row == this.defaultsignature ? "Y" : "N");
  107.             case "description":
  108.               return this.items[row].description;
  109.             case "path":
  110.               return this.items[row].path;
  111.             case "shortcut":
  112.               return this.items[row].shortcut;
  113.             case "addresses":
  114.               return this.items[row].addresses;
  115.             case "newsgroups":
  116.               return this.items[row].newsgroups;
  117.             case "mailinglists":
  118.               return this.items[row].mailinglists;
  119.             default:
  120.               return "";
  121.         }
  122.     },
  123.  
  124.     setTree: function(treebox)
  125.     {
  126.         this.treebox = treebox;
  127.     },
  128.  
  129.     cycleCell: function(row, column)
  130.     {
  131.         if ((typeof(column) == "object" ? column.id : column) == "default")
  132.         {
  133.             if (row == this.defaultsignature)
  134.             {
  135.                 this.defaultsignature = -1;
  136.             }
  137.             else
  138.             {
  139.                 var currDef = this.defaultsignature;
  140.                 this.defaultsignature = row;
  141.                 this.items[row].isVisible = true;
  142.                 this.treebox.invalidateCell(currDef, column);
  143.             }
  144.         }
  145.  
  146.         // this.treebox.selection.select(row);
  147.         this.selection.select(row);
  148.         this.treebox.invalidateRow(row);
  149.     },
  150.  
  151.     getImageSrc: function(row, column)
  152.     {
  153.         if ((typeof(column) == "object" ? column.id : column) == "default")
  154.         {
  155.             if (row == this.defaultsignature)
  156.                 return "chrome://signatureswitch/skin/default.png";
  157.         }
  158.  
  159.         return null;
  160.     },
  161.  
  162.     get rowCount()
  163.     {
  164.         return this.items.length;
  165.     },
  166.  
  167.     isContainer: function(row) { return false; },
  168.     isSeparator: function(row) { return false; },
  169.     isSorted: function(row) { return false; },
  170.     cycleHeader: function(col, elem) {},
  171.     getLevel: function(row) { return 0; },
  172.     getRowProperties: function(row, props) {},
  173.     getCellProperties: function(row, col, props) {},
  174.     getColumnProperties: function(colid, col, props) {}
  175. };
  176.  
  177. function treeView(items, defaultsignature)
  178. {
  179.     this.items = items;
  180.     this.defaultsignature = defaultsignature;
  181.     this.treebox = null;
  182. }
  183.  
  184. function onLoad()
  185. {
  186.     var elementID;
  187.     var element;
  188.     var eltType;
  189.     var defpref;
  190.  
  191.     setDefaultPrefsForOS();
  192.  
  193.     for (var i = 0; i < elementIDs.length; i++)
  194.     {
  195.         elementID = elementIDs[i];
  196.         element = document.getElementById(elementID);
  197.  
  198.         if  (!element) break;
  199.  
  200.         eltType = element.localName;
  201.         str.data = element.getAttribute("defaultpref");
  202.  
  203.         if  (eltType == "radiogroup")
  204.         {
  205.             try
  206.             {
  207.                 element.selectedItem = element.childNodes[pref.getIntPref(element.getAttribute("prefstring"))];
  208.             }
  209.             catch (e)
  210.             {
  211.                 element.selectedItem = element.childNodes[element.getAttribute("defaultpref")];
  212.                 try
  213.                 {
  214.                     pref.setIntPref(element.getAttribute("prefstring"), element.getAttribute("defaultpref") );
  215.                 }
  216.                 catch (e) {}
  217.             }
  218.         }
  219.         else if (eltType == "checkbox")
  220.         {
  221.             try
  222.             {
  223.                 element.checked = (pref.getBoolPref(element.getAttribute("prefstring")));
  224.             }
  225.             catch(e)
  226.             {
  227.                 defpref = element.getAttribute("defaultpref");
  228.                 element.checked = (defpref == "true");
  229.                 try
  230.                 {
  231.                     pref.setBoolPref(element.getAttribute("prefstring"), (defpref == "true"));
  232.                 }
  233.                 catch (e) {}
  234.             }
  235.         }
  236.         else if (eltType == "textbox")
  237.         {
  238.             try
  239.             {
  240.                 element.setAttribute("value", pref.getComplexValue(element.getAttribute("prefstring"), Components.interfaces.nsISupportsString).data);
  241.             }
  242.             catch (e)
  243.             {
  244.                 element.setAttribute("value", element.getAttribute("defaultpref"));
  245.                 try
  246.                 {
  247.                     pref.setComplexValue(element.getAttribute("prefstring"), Components.interfaces.nsISupportsString, str);
  248.                 }
  249.                 catch (e) {}
  250.             }
  251.         }
  252.         else if (eltType == "menulist")
  253.         {
  254.             try
  255.             {
  256.                 element.insertItemAt(0, pref.getComplexValue(element.getAttribute("prefstring"), Components.interfaces.nsISupportsString).data);
  257.                 element.selectedIndex = 0;
  258.             }
  259.             catch (e)
  260.             {
  261.                 element.insertItemAt(0, element.getAttribute("defaultpref"));
  262.                 element.selectedIndex = 0;
  263.                 try
  264.                 {
  265.                     pref.setComplexValue(element.getAttribute("prefstring"), Components.interfaces.nsISupportsString, str);
  266.                 }
  267.                 catch (e) {}
  268.             }
  269.         }
  270.     }
  271.  
  272.     initTree();
  273.     initAutoSwitchPriority();
  274.  
  275.     if (window.arguments && window.arguments[0])
  276.         document.documentElement.acceptDialog();
  277. }
  278.  
  279. function initTree()
  280. {
  281.     var treeData = loadTreeData();
  282.     var defaultSignature = -1;
  283.  
  284.     try
  285.     {
  286.         defaultSignature = parseInt(pref.getCharPref("extensions.signatureswitch.defaultsignature"));
  287.     }
  288.     catch(e) {}
  289.  
  290.     ssTree = document.getElementById("signatureswitchTree");
  291.     ssTreeView = new treeView(treeData, defaultSignature);
  292.     ssTree.view = ssTreeView;
  293.     ssTreeView.invalidate();
  294.     onSelectItem();
  295. }
  296.  
  297. function loadTreeData()
  298. {
  299.     var dataString;
  300.     var items = new Array();
  301.  
  302.     try
  303.     {
  304.         dataString = pref.getComplexValue("extensions.signatureswitch.signatures", Components.interfaces.nsISupportsString).data;
  305.  
  306.         if (dataString != "")
  307.         {
  308.             var itemStrings = dataString.split("|");
  309.  
  310.             var itemData;
  311.  
  312.             for (var i = 0; i < itemStrings.length; i ++)
  313.             {
  314.                 itemData = itemStrings[i].split("*");
  315.  
  316.                 // legacy support
  317.                 if (itemData[2] == null)
  318.                     itemData[2] = " -----";
  319.                 if (itemData[3] == null)
  320.                     itemData[3] = "-";
  321.                 if (itemData[4] == null)
  322.                     itemData[4] = "-";
  323.                 if (itemData[5] == null)
  324.                     itemData[5] = "-";
  325.  
  326.                 items.push(new createItem(  itemData[0],
  327.                                             itemData[1],
  328.                                             itemData[2],
  329.                                             itemData[3],
  330.                                             itemData[4],
  331.                                             itemData[5] ));
  332.             }
  333.         }
  334.     }
  335.     catch (e) {}
  336.  
  337.     return items;
  338. }
  339.  
  340. function initAutoSwitchPriority()
  341. {
  342.     var priorityString = pref.getCharPref("extensions.signatureswitch.autoswitchpriority");
  343.     var priorityList = document.getElementById("priorityList");
  344.  
  345.     for (var i = 0; i < priorityString.length; i++)
  346.     {
  347.         switch (priorityString.charAt(i))
  348.         {
  349.             case "A":
  350.               priorityList.appendItem(getLocalizedMessage("AutoSwitchPriority.Addresses"), "A");
  351.               break;
  352.             case "N":
  353.               priorityList.appendItem(getLocalizedMessage("AutoSwitchPriority.Newsgroups"), "N");
  354.               break;
  355.             case "M":
  356.               priorityList.appendItem(getLocalizedMessage("AutoSwitchPriority.Mailinglists"), "M");
  357.               break;
  358.         }
  359.     }
  360. }
  361.  
  362. function onDialogAccept()
  363. {
  364.     var elementID;
  365.     var element;
  366.     var eltType;
  367.  
  368.     if (    document.getElementById("shortcut_onoff_key").selectedItem.label   != pref.getCharPref("extensions.signatureswitch.shortcut_onoff_key")                 ||
  369.             document.getElementById("shortcut_onoff_modifier_accel").checked   != pref.getBoolPref("extensions.signatureswitch.shortcut_onoff_modifier_accel")      ||
  370.             document.getElementById("shortcut_onoff_modifier_alt").checked     != pref.getBoolPref("extensions.signatureswitch.shortcut_onoff_modifier_alt")        ||
  371.             document.getElementById("shortcut_onoff_modifier_control").checked != pref.getBoolPref("extensions.signatureswitch.shortcut_onoff_modifier_control")    ||
  372.             document.getElementById("shortcut_onoff_modifier_meta").checked    != pref.getBoolPref("extensions.signatureswitch.shortcut_onoff_modifier_meta")       ||
  373.             document.getElementById("shortcut_onoff_modifier_shift").checked   != pref.getBoolPref("extensions.signatureswitch.shortcut_onoff_modifier_shift")      ||
  374.             document.getElementById("shortcut_cycle_key").selectedItem.label   != pref.getCharPref("extensions.signatureswitch.shortcut_cycle_key")                 ||
  375.             document.getElementById("shortcut_cycle_modifier_accel").checked   != pref.getBoolPref("extensions.signatureswitch.shortcut_cycle_modifier_accel")      ||
  376.             document.getElementById("shortcut_cycle_modifier_alt").checked     != pref.getBoolPref("extensions.signatureswitch.shortcut_cycle_modifier_alt")        ||
  377.             document.getElementById("shortcut_cycle_modifier_control").checked != pref.getBoolPref("extensions.signatureswitch.shortcut_cycle_modifier_control")    ||
  378.             document.getElementById("shortcut_cycle_modifier_meta").checked    != pref.getBoolPref("extensions.signatureswitch.shortcut_cycle_modifier_meta")       ||
  379.             document.getElementById("shortcut_cycle_modifier_shift").checked   != pref.getBoolPref("extensions.signatureswitch.shortcut_cycle_modifier_shift")          )
  380.                 alert(getLocalizedMessage("alert.keyBindings"));
  381.  
  382.     for (var i = 0; i < elementIDs.length; i++)
  383.     {
  384.         elementID = elementIDs[i];
  385.         element = document.getElementById(elementID);
  386.  
  387.         if  (!element) break;
  388.  
  389.         eltType = element.localName;
  390.  
  391.         if  (eltType == "radiogroup")
  392.             pref.setIntPref(element.getAttribute("prefstring"), parseInt(element.value));
  393.         else if  (eltType == "checkbox")
  394.             pref.setBoolPref(element.getAttribute("prefstring"), element.checked);
  395.         else if (eltType == "textbox" && element.preftype == "int")
  396.             pref.setIntPref(element.getAttribute("prefstring"), parseInt(element.getAttribute("value")));
  397.         else if (eltType == "textbox")
  398.         {
  399.             str.data = element.value;
  400.             pref.setComplexValue(element.getAttribute("prefstring"), Components.interfaces.nsISupportsString, str);
  401.         }
  402.         else if (eltType == "menulist")
  403.         {
  404.             str.data = element.selectedItem.label;
  405.             pref.setComplexValue(element.getAttribute("prefstring"), Components.interfaces.nsISupportsString, str);
  406.         }
  407.     }
  408.  
  409.     saveTreeData();
  410.     saveAutoSwitchPriority();
  411. }
  412.  
  413. function saveTreeData()
  414. {
  415.     var dataString = "";
  416.     var rowCount = ssTreeView.rowCount;
  417.  
  418.     for (var i = 0; i < rowCount ; i++)
  419.     {
  420.         if (dataString == "")
  421.         {
  422.             dataString =    ssTreeView.getCellText(i, "description")    + "*" +
  423.                             ssTreeView.getCellText(i, "path")           + "*" +
  424.                             ssTreeView.getCellText(i, "shortcut")       + "*" +
  425.                             ssTreeView.getCellText(i, "addresses")      + "*" +
  426.                             ssTreeView.getCellText(i, "newsgroups")     + "*" +
  427.                             ssTreeView.getCellText(i, "mailinglists");
  428.         }
  429.         else
  430.         {
  431.             dataString =    dataString + "|" +
  432.                             ssTreeView.getCellText(i, "description")    + "*" +
  433.                             ssTreeView.getCellText(i, "path")           + "*" +
  434.                             ssTreeView.getCellText(i, "shortcut")       + "*" +
  435.                             ssTreeView.getCellText(i, "addresses")      + "*" +
  436.                             ssTreeView.getCellText(i, "newsgroups")     + "*" +
  437.                             ssTreeView.getCellText(i, "mailinglists");
  438.         }
  439.     }
  440.  
  441.     str.data = dataString;
  442.     pref.setComplexValue("extensions.signatureswitch.signatures", Components.interfaces.nsISupportsString, str);
  443.     pref.setCharPref("extensions.signatureswitch.defaultsignature", ssTreeView.defaultsignature);
  444. }
  445.  
  446. function saveAutoSwitchPriority()
  447. {
  448.     var priorityList = document.getElementById("priorityList");
  449.  
  450.     var priorityString = "";
  451.  
  452.     for (var i = 0; i < priorityList.getRowCount(); i++)
  453.     {
  454.         priorityString = priorityString + priorityList.getItemAtIndex(i).value;
  455.     }
  456.  
  457.     pref.setCharPref("extensions.signatureswitch.autoswitchpriority", priorityString);
  458. }
  459.  
  460. function onDialogCancel()
  461. {
  462. }
  463.  
  464. function onSelectItem()
  465. {
  466.     var selIdx = ssTreeView.selection.currentIndex;
  467.     var rowCount = ssTreeView.rowCount;
  468.  
  469.     document.getElementById("up").disabled = selIdx <= 0;
  470.     document.getElementById("down").disabled = selIdx < 0 || selIdx >= rowCount - 1;
  471.     document.getElementById("delete").disabled = selIdx < 0;
  472.     document.getElementById("edit").disabled = selIdx < 0;
  473.  
  474.     return true;
  475. }
  476.  
  477. function onSelectPriority()
  478. {
  479.     var priorityList = document.getElementById("priorityList");
  480.     var selIdx = priorityList.selectedIndex;
  481.     var rowCount = priorityList.getRowCount();
  482.  
  483.     document.getElementById("priorityUp").disabled = selIdx <= 0;
  484.     document.getElementById("priorityDown").disabled = selIdx < 0 || selIdx >= rowCount - 1;
  485.  
  486.     return true;
  487. }
  488.  
  489. function setDefaultPrefsForOS()
  490. {
  491.     var composerPath = document.getElementById("composerpath");
  492.     var standardComposer;
  493.  
  494.     switch (getOS())
  495.     {
  496.           case "win32":
  497.             standardComposer = "C:\\Windows\\system32\\notepad.exe";
  498.             break;
  499.           case "linux":
  500.             standardComposer = "/usr/bin/gedit";
  501.             break;
  502.           case "macosx":
  503.             standardComposer = "/Applications/TextEdit.app/Contents/MacOS/TextEdit";
  504.             break;
  505.           default:
  506.             standardComposer = "/usr/bin/gedit";
  507.             break;
  508.     }
  509.  
  510.     composerPath.setAttribute("defaultpref", standardComposer);
  511. }
  512.  
  513. function getOS()
  514. {
  515.     var np = navigator.platform;
  516.     var ua = navigator.userAgent;
  517.  
  518.     var rv;
  519.  
  520.     if (np.indexOf("Win") == 0)
  521.         rv = "win32";
  522.     else if (np.indexOf("Linux") == 0)
  523.         rv = "linux";
  524.     else if (ua.indexOf("Mac OS X") != -1)
  525.         rv = "macosx";
  526.     else if (np.indexOf("Mac") != -1)
  527.         rv = "macos";
  528.     else
  529.         rv = null;
  530.  
  531.     return rv;
  532. }
  533.  
  534. function onPickComposer()
  535. {
  536.     return pickFile(getLocalizedMessage("options.pickComposerTitle"), document.getElementById("composerpath"));
  537. }
  538.  
  539. function onPickPreLoadExecutable()
  540. {
  541.     return pickFile(getLocalizedMessage("options.pickPreLoadExecutableTitle"), document.getElementById("preloadexecutablepath"));
  542. }
  543.  
  544. function pickFile(localizedTitle, textElement)
  545. {
  546.     var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker);
  547.     fp.init(window, localizedTitle, Components.interfaces.nsIFilePicker.modeOpen);
  548.     fp.appendFilters(Components.interfaces.nsIFilePicker.filterAll);
  549.  
  550.     var res = fp.show();
  551.  
  552.     if (res == Components.interfaces.nsIFilePicker.returnOK)
  553.         textElement.value = fp.file.path;
  554.  
  555.     return true;
  556. }
  557.  
  558. function newItem()
  559. {
  560.     var item = new createItem("", "", " -----", "-", "-", "-");
  561.  
  562.     window.openDialog("chrome://signatureswitch/content/setsignature.xul",
  563.                       "_blank",
  564.                       "chrome,modal,resizable=yes,dependent=yes",
  565.                       item);
  566.  
  567.     if (item.path != "" && item.description != "")
  568.     {
  569.         ssTreeView.insertItem(item);
  570.         ssTreeView.invalidate();
  571.     }
  572. }
  573.  
  574. function editItem()
  575. {
  576.     var selIdx = ssTreeView.selection.currentIndex;
  577.  
  578.     if (selIdx < 0)
  579.         return;
  580.  
  581.     window.openDialog("chrome://signatureswitch/content/setsignature.xul",
  582.                       "_blank",
  583.                       "chrome,modal,resizable=yes,dependent=yes",
  584.                       ssTreeView.items[selIdx]);
  585.  
  586.     ssTreeView.invalidate();
  587. }
  588.  
  589. function deleteItem()
  590. {
  591.     ssTreeView.deleteSelectedItem();
  592.     ssTree.focus();
  593. }
  594.  
  595. function createItem(description, path, shortcut, addresses, newsgroups, mailinglists)
  596. {
  597.     this.description = description;
  598.     this.path = path;
  599.     this.shortcut = shortcut;
  600.     this.addresses = addresses;
  601.     this.newsgroups = newsgroups;
  602.     this.mailinglists = mailinglists;
  603. }
  604.  
  605. function moveItem(moveUp)
  606. {
  607.     var fromIdx = ssTreeView.selection.currentIndex;
  608.     var toIdx;
  609.  
  610.     ssTree.focus();
  611.  
  612.     if (moveUp)
  613.     {
  614.         if (fromIdx <= 0)
  615.             return;
  616.  
  617.         toIdx = fromIdx - 1;
  618.     }
  619.     else
  620.     {
  621.         if (fromIdx >= ssTreeView.rowCount - 1)
  622.             return;
  623.  
  624.         toIdx = fromIdx + 1;
  625.     }
  626.  
  627.     ssTreeView.swap(fromIdx, toIdx);
  628.     ssTreeView.invalidate();
  629.     ssTreeView.selection.select(toIdx);
  630.     ssTreeView.treebox.ensureRowIsVisible(toIdx);
  631. }
  632.  
  633. function movePriority(moveUp)
  634. {
  635.     var priorityList = document.getElementById("priorityList");
  636.     var selectedIndex = priorityList.selectedIndex;
  637.     var targetIndex = moveUp ? selectedIndex - 1 : selectedIndex + 1;
  638.     var selectedItem = priorityList.getItemAtIndex(selectedIndex);
  639.  
  640.     priorityList.focus();
  641.  
  642.     if (moveUp)
  643.     {
  644.         if (selectedIndex <= 0)
  645.            return;
  646.  
  647.         priorityList.removeItemAt(selectedIndex);
  648.         priorityList.insertItemAt(targetIndex, selectedItem.label, selectedItem.value);
  649.     }
  650.     else
  651.     {
  652.         if (selectedIndex >= priorityList.getRowCount() - 1)
  653.            return;
  654.  
  655.         if (selectedIndex == (priorityList.getRowCount() - 2))
  656.         {
  657.            priorityList.removeItemAt(selectedIndex);
  658.            priorityList.appendItem(selectedItem.label, selectedItem.value);
  659.         }
  660.         else
  661.         {
  662.            priorityList.removeItemAt(selectedIndex);
  663.            priorityList.insertItemAt(targetIndex, selectedItem.label, selectedItem.value);
  664.         }
  665.     }
  666.  
  667.     priorityList.selectItem(priorityList.getItemAtIndex(targetIndex));
  668. }
  669.  
  670. function getLocalizedMessage(msg)
  671. {
  672.     return document.getElementById("signatureswitch.locale").getString(msg);
  673. }
  674.  
  675. function openURL(aURL)
  676. {
  677.     var uri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
  678.     var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService);
  679.  
  680.     uri.spec = aURL;
  681.     protocolSvc.loadUrl(uri);
  682. }
  683.